// pages/myCook/myCook.js
import {
  HTTP
} from '../../utils/http.js'
import api from '../../utils/api.js'
import {
  config
} from '../../utils/config'
import utils from "../../utils/util"
let http = new HTTP()
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: config.imgUrl,
    page : 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getCookBook();
  },

  /*获取菜谱*/
  getCookBook() {
    let that = this
    http.request({
      url: api.mycookbooklist,
      method: "GET",
      success: (res) => {
        if (res.code == 200) {
          var subjectArray = []
          for(var idx in res.data) {  
              var temp = {
                  subjectName: idx,
                  professionArray: res.data[idx]
              }
              subjectArray.push(temp)
          }    
          that.setData({
            bookList: subjectArray
          })
        }
      }
    })
  },

  /*点击菜谱列表*/ 
  showCook(e){

    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
        url: "/pages/video/video?id=" + id
    })
},
 /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    // if(this.data.bookList.length == this.data.page*10){
    //   this.setData({
    //     page: this.data.page + 1
    //   })
    //   this.getOrderList();
    // }else{
    //   console.log("触底刷新");
    // }
    
  },
})